package org.assistant.common.utils;

import javax.servlet.http.HttpServletRequest;

public class WebUtils {
	/**
	 * 获取WEB应用程序的路径，例如：http://ip:port/contextPath <br>
	 * 注意: there is no "/" at the end of path
	 * 
	 * @param request
	 * @return
	 */
	public static String getWebRoot(HttpServletRequest request) {
		StringBuffer webPath = new StringBuffer();
		webPath.append("http://");
		webPath.append(request.getServerName());
		webPath.append(":");
		webPath.append(request.getServerPort());
		if (!request.getContextPath().equals("")) {
			webPath.append(request.getContextPath());
		}
		return webPath.toString();
	}
}
